package com.loveprogrammer.eternity.model.affix.levelone;

import com.loveprogrammer.eternity.enums.QualityEnum;
import com.loveprogrammer.eternity.model.affix.Affix;
import com.loveprogrammer.eternity.model.product.Equipment;

import java.util.Random;

/**
 * @version 1.0.0
 * @description: 力之前缀
 * @author: eric
 * @date: 2022-08-24 17:59
 **/
public class StrengthAffix implements Affix {

    private final int base = 3;

    @Override
    public Equipment addEffect(Equipment equipment) {
        String name = equipment.getName();
        equipment.setName(affix() + name);
        // 计算增加的值
        QualityEnum quality = equipment.getQuality();
        int level = equipment.getLevel();
        int addMax = (int) ((base * Math.pow((level/5.0 + 1),2.0) / 5 + base * 2) * quality.getRatio() * ratio_level_one);
        int addMin = addMax/2;

        equipment.setStrength(equipment.getStrength() + addMin + new Random().nextInt(addMax - addMin));
        return equipment;
    }

    @Override
    public int group() {
        return 1;
    }

    @Override
    public String affix() {
        return "力之";
    }
}
